import {
  codeSelect,
  getCodeListFromCacheByType,
  codeCompositeSelect,
  codeInsert,
  codUpdate,
  codeDeleteState,
  codeDelete
} from '@/api/service'
const system = {
  actions: {
    // 码表检索
    CodeSelect({ commit }, postselectinfo) {
      return new Promise((resolve, reject) => {
        codeSelect(postselectinfo).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 码表缓存检索
    getCodeListFromCacheByType({ commit }, args) {
      return new Promise((resolve, reject) => {
        getCodeListFromCacheByType(args).then(response => {
          resolve(response.data)
    }).catch(error => {
        reject(error)
      })
    })
    },
    // 码表复合检索
    CodeCompositeSelect({ commit }, postselectinfo) {
      return new Promise((resolve, reject) => {
        codeCompositeSelect(postselectinfo).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 码表插入
    CodeInsert({ commit }, postselectinfo) {
      return new Promise((resolve, reject) => {
        codeInsert(postselectinfo).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 码表更新
    CodUpdate({ commit }, postselectinfo) {
      return new Promise((resolve, reject) => {
        codUpdate(postselectinfo).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 码表删除（更改状态）
    CodeDeleteState({ commit }, postselectinfo) {
      return new Promise((resolve, reject) => {
        codeDeleteState(postselectinfo).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 码表删除（强制）
    CodeDelete({ commit }, postselectinfo) {
      return new Promise((resolve, reject) => {
        codeDelete(postselectinfo).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}

export default system
